<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/adminTemp.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns="http://www.w3.org/1999/xhtml">
    <ui:define name="content">
        <section class="grid_8 first">
            <div class="columns">
                <div class="grid_6 first">
                    <h:form prependId="false" styleClass="form panel" id="form">
                        <p:dataTable value="#{classManagedBean.all}" var="c"
                                     paginator="true" rows="10"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                                     rowsPerPageTemplate="10">
                            <h:inputHidden value="#{c.classId}"/>
                            <p:column>
                                <f:facet name="header">Class name</f:facet>
                                <h:commandLink value="#{c.className}" action="classdetail">
                                    <f:setPropertyActionListener value="#{c}" target="#{classManagedBean.classBean}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column>
                                <f:facet name="header">Branch</f:facet>
                                <h:outputText value="#{classManagedBean.branchNameById(c.branchId).branchName}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">Semester</f:facet>
                                <h:outputText value="#{classManagedBean.semesterNameById(c.semesterId)}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">Teacher</f:facet>
                                <h:outputText value="#{classManagedBean.staffNameById(c.teacherId)}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">Start Date</f:facet>
                                <h:outputText value="#{c.startDate}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+7"/>
                                </h:outputText>
                            </p:column>
                            <p:column>
                                <f:facet name="header">Edit/Delete</f:facet>
                                <h:commandButton value="Edit" styleClass="button-orange" action="classdetail">
                                    <f:setPropertyActionListener value="#{c}" target="#{classManagedBean.classBean}"/>
                                </h:commandButton><br/>
                                <h:commandButton value="Delete" styleClass="button-gray" action="#{classManagedBean.delete}">
                                    <f:setPropertyActionListener value="#{c}" target="#{classManagedBean.classBean}"/>
                                </h:commandButton>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </div>
            </div>
        </section>
    </ui:define>

</ui:composition>

